import { Module } from 'vuex'
import { minCache } from '@/utils/min-cache'

interface State {
  appInfo: appInfo //用户基本数据
  nightMode: boolean //是否暗黑模式
  locationUrl: any // 存储域名
}

interface appInfo {
  accessDomain: string
  platform: string
}

const store: Module<State, unknown> = {
  namespaced: true,
  state() {
    return {
      appInfo: {
        accessDomain: '',
        platform: '',
        channelCode: '',
      },
      nightMode: false,
      locationUrl: {},
    }
  },
  getters: {
    getAppBaseInfo(state) {
      return state.appInfo
    },
  },
  mutations: {
    setAppBaseInfo(state, value) {
      state.appInfo = value
      minCache.set('appInfo', value)
    },
    setAppNightMode(state, value) {
      state.nightMode = value
      minCache.set('theme', value)
    },
  },

  actions: {},
}

export default store
